use std::vec;

trait Draw {
    fn draw(&self);
}

struct Screen {
    components: Vec<Box<dyn Draw>>
}

impl Screen {
    fn run(&self) {
        for item in &self.components {
            item.draw();
        }
    }
    fn new() -> Screen {
        Screen {
            components: vec![]
        }
    }
}

struct Button {
    width: i32,
    height: i32,
    label: String
}

impl Draw for Button {
    fn draw(&self) {
        println!("The width: {}, the height: {}, the label: {}", self.width, self.height, self.label)
    }
}

struct Selection {
    options: Vec<i32>,
    width: i32,
    height: i32
}

impl Draw for Selection {
    fn draw(&self) {
        println!("The width: {}, the height: {}, the options is {:?}", self.width, self.height, self.options)
    }
}

fn main() {
    let mut screen = Screen::new();
    screen.components = vec![
        Box::new(Button {
            width: 12,
            height: 12,
            label: String::from("hello")
        }),
        Box::new(Selection{
            options: vec![1,2,3],
            width: 12,
            height: 13
        })
    ];
    screen.run()
}